---
keywords:
  - Smart Contracts
  - view
  - account
  - balances
  - Rust
  - Solo
description: The Accounts contract provides the balance, totalAssets and accounts views.
image: /img/logo/WASP_logo_dark.png
---

import Tabs from "@theme/Tabs"
import TabItem from "@theme/TabItem"

# View Account Balances

The Accounts contract provides the following views:

## balance

Get the account balance of a specific account.

### Parameters

- `ParamAgentID`: account's AgentID.

### Returns

- A map of [token_color] -> [amount].

### Examples

<Tabs
    defaultValue="solo"
    values={[
        {label: 'Solo', value: 'solo'},
        {label: 'Solo (Schema)', value: 'soloctx'},
        {label: 'Rust (Schema)', value: 'rust'},
        {label: 'Go (Schema)', value: 'go'},
    ]}>
<TabItem value="solo">

```go
balances := chain.GetAccountBalance(agentID)
// require.NoError(t, ctx.Err) // happens in GetAccountBalance() wrapper function
```

</TabItem>
<TabItem value="soloctx">

```go
b := coreaccounts.ScFuncs.Balance(ctx)
b.Params.AgentID().SetValue(agentID)
b.Func.Call()
require.NoError(t, ctx.Err)
balances := b.Results.Balances()
```

</TabItem>
<TabItem value="rust">

```rust
let b = coreaccounts::ScFuncs::balance(ctx);
b.params.agent_id().set_value(&agentID);
b.func.call();
let balances = b.results.balances();
```

</TabItem>
<TabItem value="go">

```go
b := coreaccounts.ScFuncs.Balance(ctx)
b.Params.AgentID().SetValue(agentID)
b.Func.Call()
balances := b.Results.Balances()
```

</TabItem>
</Tabs>

---

## totalAssets

Get the total colored balances controlled by the chain.

### Returns

- A map of [token_color] -> [amount] .

<Tabs
    defaultValue="solo"
    values={[
        {label: 'Solo', value: 'solo'},
        {label: 'Solo (Schema)', value: 'soloctx'},
        {label: 'Rust (Schema)', value: 'rust'},
        {label: 'Go (Schema)', value: 'go'},
    ]}>
<TabItem value="solo">

```go
balances:= chain.GetTotalAssets()
```

</TabItem>
<TabItem value="soloctx">

```go
b := coreaccounts.ScFuncs.TotalAssets(ctx)
b.Func.Call()
require.NoError(t, ctx.Err)
balances := b.Results.Balances()
```

</TabItem>
<TabItem value="rust">

```rust
let b = coreaccounts::ScFuncs::total_assets(ctx);
b.func.call();
let balances = b.results.balances();
```

</TabItem>
<TabItem value="go">

```go
b := coreaccounts.ScFuncs.TotalAssets(ctx)
b.Func.Call()
balances := b.Results.Balances()
```

</TabItem>
</Tabs>

---

## accounts

Get a list of all accounts existing on the chain.

### Returns

- A list of accounts (AgentIDs).

<Tabs
    defaultValue="solo"
    values={[
        {label: 'Solo', value: 'solo'},
        {label: 'Solo (Schema)', value: 'soloctx'},
        {label: 'Rust (Schema)', value: 'rust'},
        {label: 'Go (Schema)', value: 'go'},
    ]}>
<TabItem value="solo">

```go
accounts := chain.GetAccounts()
```

</TabItem>
<TabItem value="soloctx">

```go
a := coreaccounts.ScFuncs.Accounts(ctx)
a.Func.Call()
require.NoError(t, ctx.Err)
accounts := a.Results.Agents()
```

</TabItem>
<TabItem value="rust">

```rust
let a = coreaccounts::ScFuncs::accounts(ctx);
a.func.call();
let accounts = a.results.agents();
```

</TabItem>
<TabItem value="go">

```go
a := coreaccounts.ScFuncs.Accounts(ctx)
a.Func.Call()
accounts := a.Results.Agents()
```

</TabItem>
</Tabs>

---

## getAccountNonce

Get the current nonce for a given account.

### Parameters

- `ParamAgentID`: Account's AgentID.

#### Returns

- The current nonce.

<Tabs
    defaultValue="solo"
    values={[
        {label: 'Solo', value: 'solo'},
        {label: 'Solo (Schema)', value: 'soloctx'},
        {label: 'Rust (Schema)', value: 'rust'},
        {label: 'Go (Schema)', value: 'go'},
    ]}>
<TabItem value="solo">

```go
ret, err := chain.CallView(accounts.Contract.Name, accounts.FuncGetAccountNonce.Name,
    accounts.ParamAgentID, iscp.NewAgentID(address, 0),
)
require.NoError(t, err)
nonce, _, err := codec.DecodeUint64(ret.MustGet(accounts.ParamAccountNonce)
```

</TabItem>
<TabItem value="soloctx">

```go
n := coreaccounts.ScFuncs.GetAccountNonce(ctx)
n.Params.AgentID().SetValue(agentID)
n.Func.Call()
require.NoError(t, ctx.Err)
nonce := n.Results.AccountNonce().Value()
```

</TabItem>
<TabItem value="rust">

```rust
let n = coreaccounts::ScFuncs::get_account_nonce(ctx);
n.params.agent_id().set_value(&agentID);
n.func.call();
let nonce = n.results.account_nonce().value();
```

</TabItem>
<TabItem value="go">

```go
n := coreaccounts.ScFuncs.GetAccountNonce(ctx)
n.Params.AgentID().SetValue(agentID)
n.Func.Call()
nonce := n.Results.AccountNonce().Value()
```

</TabItem>
</Tabs>

